import { RouterName } from '../name'
import { mergeMeta } from '../merge-meta'
import { Role } from '@/constants/role'

export const classRoutes = mergeMeta(
  [
    {
      path: 'classes',
      name: RouterName.Class,
      meta: {
        hideInMenu: false,
        hideChildrenInMenu: true,
        menuTitle: 'navigation.class.title',
        icon: 'i-fluent-food-grains-24-filled'
      },
      redirect: { name: RouterName.ClassList },
      children: [
        {
          path: '',
          meta: { isLink: false },
          name: RouterName.ClassList,
          component: () => import('@/pages/ClassPage/ClassList/index.vue')
        },
        {
          path: ':classID',
          meta: { menuTitle: 'navigation.class.detail' },
          name: 'reports-to-class-detail',
          redirect(to) {
            return { name: RouterName.ClassDetail, params: to.params }
          },
          children: [
            {
              path: '',
              meta: { isLink: false },
              name: RouterName.ClassDetail,
              component: () => import('@/pages/ClassPage/ClassDetail/index.vue')
            },
            {
              path: 'reports/:courseID',
              name: RouterName.ClassReports,
              meta: {
                menuTitle: 'navigation.report.list'
              },
              component: () => import('@/pages/ReportPage/ReportList/index.vue')
            }
          ]
        }
      ]
    }
  ],
  {
    requireAuth: true,
    menuTitle: 'navigation.class.title',
    role: Role.Teacher
  }
)
